"""
@Author: 石沙
@Date: 2020-09-27
"""

from src.predict import Predictor
from flask import Flask, request
import json


app = Flask(__name__)

# 初始化模型
MODEL = Predictor(model_name='lgbm')


@app.route('/predict', methods=["POST"])
def answer():
    inputs = [{
        'title': request.form['title'],
        'content': request.form['content']
    }]
    print('打印post数据：', inputs)
    result = MODEL.predict(inputs)
    print(result)
    return json.dumps(result)


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=10001, debug=True, use_reloader=False)